<!-- 搜索项目 -->
<template>
	<h-select-input-popup ref="hSelectInputPopup" v-model="val" v-bind="$attrs" v-on="$listeners"
		:searchPlaceholder="placeholder" :params="params" :keywords.sync="keywords" :getList="getList"
		@getDetail="getDetail" @change="$emit('change', $event)">
		<template v-slot:default="{ item }">
			<view class="project-item">
				<view class="option">
					<view class="lf">用户姓名</view>
					<view class="rl">{{ item.cardRecipient_dictText }}</view>
				</view>
				<view class="option">
					<view class="lf">部门</view>
					<view class="rl">{{ item.rdeptName }}</view>
					<!-- <view class="rl">{{ item.cardRecipientDeptId_dictText }}</view> -->
				</view>
				<view class="option">
					<view class="lf">油卡卡号</view>
					<view class="rl">{{ item.cardNumber }}</view>
				</view>
			</view>
		</template>
	</h-select-input-popup>
</template>

<script>
	// import {
	// 	erpOmcProjectOilCardList
	// } from '@/api/index.js'
	import {
		erpOmcProjectOilCardInfo
	} from '@/api/index.js'

	import {
		erpOilCardManagerPopList
	} from '@/api/index.js'
	export default {
		name: 'HSelectOilCardInputPopup',
		data() {
			return {
				// getList: erpOmcProjectOilCardList,
				getList: erpOilCardManagerPopList,
				params: {
					column: 'createTime,id',
					order: 'desc',
					pageNo: 1,
					pageSize: 10,
					cardRecipientName: '',
					field: 'id,,,cardRecipient_dictText,cardRecipientDeptId_dictText,cardNumber'
				},
				keywords: '',
				placeholder: '请输入领款人姓名'
			}
		},
		model: {
			prop: 'value',
			event: 'input',
		},
		props: {
			value: {
				type: [String, Number, Array],
				default: null,
			},
		},
		watch: {
			keywords: {
				handler(val) {
					if (val) {
						this.params.pageNo = 1
						this.params.cardRecipientName = val
					} else {
						this.params.pageNo = 1
						this.params.cardRecipientName = ''
					}
				},
				immediate: true,
			},
		},
		computed: {
			val: {
				get() {
					return this.value
				},
				set() {
					this.$emit('input', this.value)
				}
			}
		},
		methods: {
			// 获取详情
			getDetail(value) {
				erpOmcProjectOilCardInfo({
					id: value
				}).then((res) => {
					if (res.success) {
						this.$refs.hSelectInputPopup.title = res.result.cardRecipient_dictText
						this.$emit('select', {
							data: res.result,
							id: value
						})
					}
				})
			},
		},
	}
</script>

<style lang="scss" scoped>
	// 按钮
	.btn {
		position: fixed;
		bottom: 20rpx;
		width: 95%;
	}
</style>